//统一管理项目的全部的接口
import requests from "./request";
import requestMock from '@/api/requestMock'
//商品分类的接口
//api/product/getBaseCategoryList   GET  无参数
//axios写法有几种:函数写法、对象写法
//切记:统一封装的接口函数，务必要有return，只不过上面写法是简写
export const reqCategory = ()=>requests({url:'/product/getBaseCategoryList',method:'get'});

//获取banner轮播图的接口函数
export const reqBannerList = ()=>requestMock({url:'/banner',method:'get'});

//获取floor底部组件的接口函数
export const reqFloorList = ()=>requestMock({url:'/floor',method:'get'});

//获取搜索商品的接口
//api/list   post   携带参数【最多十个】
//data:将来发请求的时候携带参数（请求体）对象，最多十个参数[可有可无]
export const reqSearchList = (data)=>requests({url:'/list',method:'post',data});
//请求函数:务必要携带参数,至少是一个空对象
/*
{
  "category1Id": "61",//一级分类的ID
  "category2Id": "61",//二级分类的ID
  "category3Id": "61",//三级分类的ID
  "categoryName": "手机",//商品的名字
  "keyword": "小米",//关键字
  "order": "2:desc",//用于排序的参数
  "pageNo": 5, //当前第几页设置
  "pageSize": 3,//返回数据的条数
  "props": ["1:1700-2799:价格", "2:6.65-6.74英寸:屏幕尺寸"],//平台属性需要携带的参数
  "trademark": "4:小米"//品牌
}
*/


//商品详情接口
///api/item/{ skuId }  get请求
export const reqGoodDetail = (skuId)=>requests({url:`/item/${skuId}`,method:'get'});

//可以把商品加入购物车|修改某一个商品的数量的个数---两个
///api/cart/addToCart/{ skuId }/{ skuNum }   post  skuId:商品的id、产品的个数
export const reqAddCartOrUpdateSkuNum = (skuId,skuNum)=>requests({url:`/cart/addToCart/${skuId}/${skuNum}`,method:'post'});


//获取购物车列表接口函数
//api/cart/cartList   get
export const reqCartList = ()=>requests({url:`/cart/cartList`,method:'get'});



//修改某一个商品的勾选状态【只能修改一个商品的选中状态】
///api/cart/checkCart/{skuId}/{isChecked}   get 
export const reqUpdateCartChecked =(skuId,isChecked)=>requests({url:`/cart/checkCart/${skuId}/${isChecked}`,method:'get'});


//删除某一个商品的接口
///api/cart/deleteCart/{skuId}  delete
export const reqDeleteCart = (skuId)=>requests({url:`/cart/deleteCart/${skuId}`,method:'delete'});


//获取验证码
export const reqGetCode = (phone)=>requests({url:`/user/passport/sendCode/${phone}`,method:'get'});

//注册用户
///api/user/passport/register post  phone|password|code
export const reqUserRegister = (data)=>requests({url:`/user/passport/register`,method:'post',data});


//登录
///api/user/passport/login  POST 
export const reqUserLogin = (data)=>requests({url:`/user/passport/login`,method:'post',data});


//获取用户信息
export const reqUserInfo = ()=>requests({url:`/user/passport/auth/getUserInfo`,method:'get'});


//退出登录
///api/user/passport/logout  get
export const reqLogout = ()=>requests({url:`/user/passport/logout`,method:'get'});


//获取用户地址信息
export const reqUserAddress = ()=>requests({url:`/user/userAddress/auth/findUserAddressList`,method:'get'});


//获取订单交易页信息
export const reqTradeInfo = ()=>requests({url:`/order/auth/trade`,method:'get'});


//提交订单接口（获取交易订单号）
//api/order/auth/submitOrder?tradeNo={tradeNo}
export const reqSubmitOrder = (tradeNo,data)=>requests({url:`/order/auth/submitOrder?tradeNo=${tradeNo}`,method:'post',data});



//获取订单支付信息(包含二维码)
///api/payment/weixin/createNative/{orderId}  get
export const reqPayInfo = (orderId)=>requests({url:`/payment/weixin/createNative/${orderId}`,method:'get'});


//可以查询用户支付情况
export const reqPayResult = (orderId)=>requests({url:`/payment/weixin/queryPayStatus/${orderId}`,method:'get'});



